namespace CSharppro._1016;
//1016
public class Demo1
{
   //1
   public void Print1()
   {
      int a, b, c;
      a = int.Parse(Console.ReadLine());
      b = int.Parse(Console.ReadLine());
      c = int.Parse(Console.ReadLine());
      if (a > b&&b>c)
      {
         Console.WriteLine(c);Console.WriteLine(b);Console.WriteLine(a);
      }

      if (a > c && c > b)
      {
         Console.WriteLine(c);Console.WriteLine(a);Console.WriteLine(b);
      }

      if (b > c && c > a)
      {
         Console.WriteLine(a);Console.WriteLine(c);Console.WriteLine(b);
      }

      if (a > c && c > b)
      {
         Console.WriteLine(b);Console.WriteLine(c);Console.WriteLine(a);
      }

      if (b > c && c > a)
      {
         Console.WriteLine(a);Console.WriteLine(c);Console.WriteLine(b);
      }

      if (a > c && c > b)
      {
         Console.WriteLine(c);Console.WriteLine(c);Console.WriteLine(c);
      }
   }
   //2
   public void Print2()
   {
      for (int i = 0; i <100; i++)
      {
         if (i % 7 != 0 && i % 10 != 7)
         {
            Console.WriteLine(i);
         }
      }
   }
   //3
   public void Print3()
   {
      for (int i = 0; i < 9; i++)
      {
         for (int j = 0; j < 9; j++)
         {
            Console.WriteLine("{0}*{1}={2}",i,j,i*j);
         }
      }
   }
   //4
   public bool IsPerfectNumber(int n, out List<int> factors)
   {
      factors = new List<int>();

      if (n <= 1)
         return false;
      factors.Add(1);
      int factorsSum = 1;
      for (int i = 2; i <= Math.Sqrt(n); i++)
      {
         if (n % i == 0)
         {
            factors.Add(i);
            factorsSum += i;
            int counterpart = n / i;
            if (counterpart != i)
            {
               factors.Add(counterpart);
               factorsSum += counterpart;
            }
         }
      }
      factors.Sort();
      return factorsSum == n;
   }
   public List<int> FindPerfectNumbers(int limit)
   {
      List<int> perfectNumbers = new List<int>();
            
      for (int num = 2; num <= limit; num++)
      {
         if (IsPerfectNumber(num, out _))
         {
            perfectNumbers.Add(num);
         }
      }
            
      return perfectNumbers;
   }
   //5
   public  int GetDigitCount(int number)
   {
      if (number <= 0)
      {
         return 0;
      }
      int count = 0;
      int temp = number;
        
      while (temp > 0)
      {
         temp /= 10;
         count++;
      }
        
      return count;
   }
   public  int ReverseAndPrintDigits(int number)
   {
      if (number <= 0)
      {
         return 0;
      }
        
      int reversedNumber = 0;
      int temp = number;
        
      Console.Write("逆序的各位数字：");
      while (temp > 0)
      {
         int digit = temp % 10;
         reversedNumber = reversedNumber * 10 + digit;
         Console.Write(digit + " ");
         temp /= 10;
      }
      Console.WriteLine();
        
      return reversedNumber;
   }
   //6
   public void print6(int rows)
   {
      {
         if (rows <= 0 || rows % 2 == 0)
         {
            return ;
         }

         int half = rows / 2;
         for (int i = 0; i <= half; i++)
         {
            for (int j = 0; j < half - i; j++)
            {
               Console.Write(" ");
            }

            for (int k = 0; k < 2 * i + 1; k++)
            {
               Console.Write("*");
            }

            Console.WriteLine();
         }

         for (int i = half - 1; i >= 0; i--)
         {
            for (int j = 0; j < half - i; j++)
            {
               Console.Write(" ");
            }

            for (int k = 0; k < 2 * i + 1; k++)
            {
               Console.Write("*");
            }

            Console.WriteLine();
         }

         return ;
      }
     
   }
}
